/**
 * 张晓衡
 * 2023-1-2
 * 场景加载
 */

import { _decorator, Component, SceneAsset, Node, director } from 'cc';
const {ccclass, property} = _decorator;

@ccclass('LoadScene')
export default class LoadScene extends Component {
    @property(SceneAsset)
    scene: SceneAsset | null = null;
    @property
    click: boolean = true;
   
    onLoad() {
        if (this.click) {
            this.node.on(Node.EventType.TOUCH_END, () => {
                this.loadScene();
            }, this);
        }
    };

    loadScene() {
        if (this.scene) {
            director.loadScene(this.scene.name, () => {
                console.log('场景加载成功！');
            });
        }
    }
}